package com.itheima.day06;

import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.function.Consumer;

public class Demo1 {
    public static void main(String[] args) {
        Integer[] arr={1,2,3};
        Arrays.sort(arr,(o1,o2)->o1-o2);

//        Set<Apple> sets=new TreeSet<>((o1,o2)-> o2.getWeight()- o1.getWeight()>=0?1:-1);
        Set<Apple> sets=new TreeSet<>((o1,o2)->Double.compare(o1.getPrice(),o2.getPrice()));
        Apple a1 = new Apple("a1hindsight", 23.5, 500);
        Apple a2 = new Apple("a2红富士", 213.7, 300);
        Apple a3 = new Apple("a3黄苹果", 34.8, 800);
        Apple a4 = new Apple("a4gong苹果", 27.9, 800);
        sets.add(a1);
        sets.add(a2);
        sets.add(a3);
        sets.add(a4);

        sets.forEach(apple -> System.out.println(apple));

        System.out.println(sets);

        System.out.println("--------");
       List<Apple> lists=new ArrayList<>();
       Collections.addAll(lists,a1,a2,a3,a4);
       Collections.shuffle(lists);
       Collections.sort(lists,(o1,o2)->o1.getWeight()-o2.getWeight());
        System.out.println(lists);
//        ChronoUnit.YEARS.between();


    }
}
